var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var userSchema = new Schema({
	username: String,
	password: String,
	email: String,
	isadmin: String,
	createTime: {
		type: Date,
		default: Date.now
	}
});

var articleSchema = new Schema({
	title: String,
	author: String,
	tag: String,
	content: String,
	pv: {
		type: Number,
		default: 0
	},
	createTime: {
		type: Date,
		default: Date.now
	}
})

var joinSchema = new Schema({
	arcId: {
		type: Schema.Types.ObjectId,
		ref: 'articleSchema'
	},
	userId: {
		type: Schema.Types.ObjectId,
		ref: 'userSchema'
	},
	createTime: {
		type: Date,
		default: Date.now
	}
})

exports.User = mongoose.model('User', userSchema);
exports.Article = mongoose.model('Article', articleSchema);
exports.Join = mongoose.model('Join', joinSchema);